****************************************************************************
*
*      Programa que junta todo os registro em uma so dbf
*
*      Autor: Eng. Luis Lin
*
*      Date : 26.09.97
*
****************************************************************************
local cod
priv ncount
REQUEST DBFCDX
RddSetDefault('dbfcdx')
close databases
set deleted off

   use prod index ccodp new alias PR
   set order to tag ccodpro
   use prod1  new alias PR1
   use estoque index eccodp new alias ET
   set order to tag eccodpro
   use estoque1 new alias ET1
   sele ET
   go top
   sele ET1
   go top
   sele PR
   go top
   sele PR1
   go top

   do while ! eof()
       cod := PR1->pr_ccodpro
       sele PR
       go top
       seek cod
       if ! found()
          append blank
       endif

       PR->PR_CCODPRO  := PR1-> PR_CCODPRO
       PR->PR_CCODFOR  := PR1-> PR_CCODFOR
       PR->PR_CNOMPRO  := PR1-> PR_CNOMPRO
       PR->PR_CNOMPR1  := PR1-> PR_CNOMPR1
       PR->PR_NCFT     := PR1-> PR_NCFT
       PR->PR_NCOTA    := PR1-> PR_NCOTA
       PR->PR_NNUMGI   := PR1-> PR_NNUMGI
       PR->PR_NNUMDI   := PR1-> PR_NNUMDI
       PR->PR_NDIE     := PR1-> PR_NDIE
       PR->PR_DDATEDI  := PR1-> PR_DDATEDI
       PR->PR_NCLASFI  := PR1-> PR_NCLASFI
       PR->PR_NQTY     := PR1-> PR_NQTY
       PR->PR_CUNID    := PR1-> PR_CUNID
       PR->PR_NQTY_CX  := PR1-> PR_NQTY_CX
       PR->PR_CFT      := PR1-> PR_CFT
       PR->PR_NSALDO   := PR1-> PR_NSALDO
       PR->PR_NPESOLI  := PR1-> PR_NPESOLI
       PR->PR_NPESOBR  := PR1-> PR_NPESOBR
       PR->PR_CSITTRI  := PR1-> PR_CSITTRI
       PR->PR_NIPI     := PR1-> PR_NIPI
       PR->PR_NPRECUS  := PR1-> PR_NPRECUS
       PR->PR_NPREUNI  := PR1-> PR_NPREUNI
       PR->PR_NPORCEN  := PR1-> PR_NPORCEN
       PR->PR_NPRECO1  := PR1-> PR_NPRECO1
       PR->PR_NPRECO2  := PR1-> PR_NPRECO2
       PR->PR_NPRECO3  := PR1-> PR_NPRECO3
       PR->PR_NPRECO4  := PR1-> PR_NPRECO4
       PR->PR_NPREVEN  := PR1-> PR_NPREVEN
       PR->PR_DDATCAD  := PR1-> PR_DDATCAD
       PR->PR_DDATULT  := PR1-> PR_DDATULT
       if deleted()
          delete
       endif
       sele PR1
       skip
  enddo


   sele ET1
   go top
   do while ! eof()
       cod := ET1->ccodpro
       sele ET
       go top
       seek cod
       if ! found()
          append blank
       endif
       ET->CCODPRO  :=  ET1->CCODPRO
       ET->NGI      :=  ET1->NGI
       ET->NDI      :=  ET1->NDI
       ET->NDIE     :=  ET1->NDIE
       ET->DDI      :=  ET1->DDI
       ET->DDATCAD  :=  ET1->DDATCAD
       ET->DDATENT1 :=  ET1->DDATENT1
       ET->DDATENT2 :=  ET1->DDATENT2
       ET->DDATENT3 :=  ET1->DDATENT3
       ET->DDATSAI1 :=  ET1->DDATSAI1
       ET->DDATSAI2 :=  ET1->DDATSAI2
       ET->DDATSAI3 :=  ET1->DDATSAI3
       ET->NQTY     :=  ET1->NQTY
       ET->QTYE1    :=  ET1->QTYE1
       ET->QTYE2    :=  ET1->QTYE2
       ET->QTYE3    :=  ET1->QTYE3
       ET->QTYS1    :=  ET1->QTYS1
       ET->QTYS2    :=  ET1->QTYS2
       ET->QTYS3    :=  ET1->QTYS3
       ET->SEL      :=  ET1->SEL
       ET->NQTYCX   :=  ET1->NQTYCX
       if deleted()
          delete
       endif
       sele ET1
       skip
 enddo
 close databases
 return .t.


Function DispBar()
LOCAL nCount := 0
Public nRec
@ 19,18,21,61 BOX B_DOUBLE
@ 20,19 clear to 20,60
@ 20,20 say chr(219)
nCount := 0
nRec := Reccount() / 40
return nCount

Function dacCount(xStr, nCount)
*Public nRec
IF  nCount == NIL
    RETURN xStr
END
nCount ++
if nCount > nRec
   @ 20, col() say chr(219)
   nCount := 0
endif
RETURN xStr

